require_relative "../Expr"

# Expression for representing real numbers
#
# @author Paul T.
class Calcula::Exprs::NumExpr < Calcula::Expr

  # @param num [Calcula::Token] The token should have the type of NUM
  def initialize(num)
    @num = num
  end

  # @see Calcula::Expr#to_s
  # @param (see Calcula::Expr#to_s)
  # @return (see Calcula::Expr#to_s)
  def to_s(form: :src)
    case form
    when :src then
      @num.text
    when :tree then
      "(num #{@num.text})"
    when :ruby then
      "#{@num.text}r"
    else
      nil
    end
  end

  # @see Calcula::Expr#children
  # @param (see Calcula::Expr#children)
  # @return (see Calcula::Expr#children)
  def children
    []
  end
end
